/// <reference path="fKanban.js" />
/// <reference path="fKanban.user.js" />

/* fKanban.goal */
fKanban.goal = function () { }
fKanban.goal.prototype = new fKanban();
fKanban.goal.prototype.constructor = fKanban.goal;
fKanban.goal.prototype.supr = fKanban.prototype;

//add
fKanban.goal.prototype.add = function (item, fn_successful) {
    $.ajax({
        type: "POST",
        url: website + "Online/AddSprintGoal",
        dataType: "json",
        data: item,
        success: function (result) {
            if (fn_successful) fn_successful(result);
        },
        error: function (err) {
            Info(err);
        }
    });
};

//update
fKanban.goal.prototype.update = function (item, fn_successful) {
    $.ajax({
        type: "POST",
        url: website + "Online/UpdateSprintGoal",
        dataType: "json",
        data: item,
        success: function (result) {
            if (fn_successful) fn_successful(result);
        },
        error: function (err) {
            Info(err);
        }
    });
};

//remove
fKanban.goal.prototype.remove = function (id, fn_successful) {
    $.ajax({
        type: "POST",
        url: website + "Online/RemoveSprintGoal",
        dataType: "json",
        data: { id: parseInt(id) },
        success: function (result) {
            if (fn_successful) fn_successful(result);
        },
        error: function (err) {
            Info(err);
        }
    });
};

//loadData
fKanban.goal.prototype.loadData = function (callback, onerror) {
    $.ajax({
        type: "POST",
        url: website + "Online/LoadSprintGoals",
        dataType: "json",
        data: { },
        success: function (obj) {
            Info(obj.Message);
            if (callback) callback(obj.Result);
        },
        error: function (err) {
            Info(err);
        }
    });
};

//loadDataBySprintId
fKanban.goal.prototype.loadDataBySprintId = function (sprintId, callback, onerror) {
    $.ajax({
        type: "POST",
        url: website + "Online/LoadSprintGoalsBySprintId",
        dataType: "json",
        data: { sprintId: sprintId },
        success: function (obj) {
            Info(obj.Message);
            if (callback) callback(obj.Result);
        },
        error: function (err) {
            Info(err);
        }
    });
};